<template>
  <div id="app" style="height: 100%; width: 100%; position: absolute; top: 5%; left: 0;">
    <div class="big" style="margin-top: 10px;height: 100%;width: 35%">
      <div className="info-container">
        <div class="info-item" >
          <span>📅2025年度评审项目总数：</span>
          <span>{{ totalProjects }}</span>
        </div>
        <div class="info-item" >
          <span>⏰评审截止时间：</span>
          <span>{{ deadline }}</span>
        </div>
        <div class="info-item" >
          <span>📝评审状态：</span>
          <span>{{ status }}</span>
        </div>
        <div class="info-item">
          <span>👤评审专家总数：</span>
          <span>{{ expertCount }}</span>
        </div>
        <div class="info-item">
          <span>✅已完成评审项目数：</span>
          <span>{{ completedProjects }}</span>
        </div>
        <div class="info-item">
          <span>❌未完成评审项目数：</span>
          <span>{{ uncompletedProjects }}</span>
        </div>
      </div>
    </div>
    <div id="chart-container" ref="chartContainer"></div>
  </div>
</template>


<script>
import * as echarts from 'echarts';

export default {
  name: 'EchartsDemo',
  data() {
    return {
      totalProjects: 0,
      deadline: '',
      status: '',
      expertCount: 0,
      completedProjects: 0,
      uncompletedProjects: 0
    };
  },
  mounted() {
    this.initChart();
    window.addEventListener('resize', this.resizeChart);
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.resizeChart);
  },
  methods: {
    initChart() {
      const chartContainer = this.$refs.chartContainer;
      this.myChart = echarts.init(chartContainer, null, {
        renderer: 'canvas',
        useDirtyRect: false
      });
      const option = {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        series: [
          {
            name: '科技进步奖',
            type: 'pie',
            radius: '50%',
            data: [
              { value: this.completedProjects, name: '已完成' }, // Completed
              { value: this.uncompletedProjects, name: '未完成' } // Not Completed
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };

      if (option && typeof option === 'object') {
        this.myChart.setOption(option);
      }
    },
    resizeChart() {
      this.myChart.resize();
    }
  }
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
#app {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 40vh;
}
.info-container {
  width: 30%;
  /*padding: 20px;*/
  background-color: #f9f9f9;
  border-right: 1px solid #ddd;
}

.info-item {
  padding: 10px 0; /* 上下内边距 */
  border-top: 1px solid #ddd; /* 顶部细线 */
  margin-bottom: 20px;
}

/* 第一项不需要顶部边框 */
.info-item:first-child {
  border-top: none;
}

#chart-container {
  position: relative;
  width: 70%;
  height: 80vh;
  overflow: hidden;
}

/* 媒体查询 在999px - 2401px内显示全部数据 */

/* 默认样式 - 当屏幕宽度不在指定范围内时使用 */
.big {
  font-size: 28px; /* 这个值对应于最大的屏幕宽度（2401-2600px）的字体大小 */
}

@media screen and (max-width: 2401px) {
  .big {
    font-size: 28px;
  }
}

/*80%*/
@media screen and (min-width: 2301px) and (max-width: 2400px) {
  .big {
    font-size: 26px;
  }
  .info-item {
    padding: 18px 0; /* 上下内边距 */
  }
}

@media screen and (min-width: 2201px) and (max-width: 2300px) {
  .big {
    font-size: 26px;
  }
  .info-item {
    padding: 12px 0; /* 上下内边距 */
  }
}

/*90%*/
@media screen and (min-width: 2101px) and (max-width: 2200px) {
  .big {
    font-size: 26px;
  }
  .info-item {
    padding: 10px 0; /* 上下内边距 */
  }
}

@media screen and (min-width: 2000px) and (max-width: 2100px) {
  .big {
    font-size: 25px;
  }
}
/*100%*/
@media screen and (min-width: 1900px) and (max-width: 1999px) {
  .big {
    font-size: 20px;
    padding: 10px 0; /* 上下内边距 */
  }
}

@media screen and (min-width: 1800px) and (max-width: 1899px) {
  .big {
    font-size: 20px;
  }
}
/*110%*/
@media screen and (min-width: 1701px) and (max-width: 1799px) {
  .big {
    font-size: 18px;
  }
}

@media screen and (min-width: 1600px) and (max-width: 1700px) {
  .big {
    font-size: 12px;
  }

}
/*125%*/
@media screen and (min-width: 1500px) and (max-width: 1599px) {
  .big {
    font-size: 15px;
  }
  .info-item {
    padding: 8px 0; /* 上下内边距 */
  }
}

@media screen and (min-width: 1400px) and (max-width: 1499px) {
  .big {
    font-size: 15px;
  }
  .info-item {
    padding: 6px 0; /* 上下内边距 */
  }
}

@media screen and (min-width: 1301px) and (max-width: 1399px) {
  .big {
    font-size: 15px;
  }
  .info-item {
    padding: 4px 0; /* 上下内边距 */
  }
}
/*150%*/
@media screen and (min-width: 1200px) and (max-width: 1299px) {
  .big {
    font-size: 17px;
  }
  .info-item {
    padding: 0; /* 上下内边距 */
  }

}

@media screen and (min-width: 1101px) and (max-width: 1199px) {
  .big {
    font-size: 15px;
  }
  .info-item {
    padding: 0; /* 上下内边距 */
  }
}
</style>
